package com.chb.utils;

import com.chb.base.UserInfo;

/**
 * @author CHB
 * @createTime 2022-8-24 9:51
 */
public class UserInfoContext {
    /**
     * 用户信息
     */
    private static final ThreadLocal<UserInfo> USER_INFO_THREAD_LOCAL = new InheritableThreadLocal<>();

    public static String getPhone() {
        return USER_INFO_THREAD_LOCAL.get().getPhone();
    }

    public static void remove() {
        USER_INFO_THREAD_LOCAL.remove();
    }

    public static UserInfo getUserInfo() {
        return USER_INFO_THREAD_LOCAL.get();
    }

    public static void setUserInfo(UserInfo userInfo) {
        USER_INFO_THREAD_LOCAL.set(userInfo);
    }
}
